package com.android.nativ;

import android.content.Context;
import android.util.Log;
import com.unity3d.player.UnityPlayer;
import android.provider.Settings.Secure;

// 原生交互管理类，这里的接口由Unity端调用
public class Interaction {
    private Context m_Context;
    private Vibration m_Vibration;
    private SimCardChecker m_SimCardChecker;
    private static Interaction m_Instance;

    public Interaction() {
        m_Context = UnityPlayer.currentActivity;
        m_Vibration = new Vibration();
        m_SimCardChecker = new SimCardChecker(m_Context);
    }

    public static Interaction getInstance() {
        if (m_Instance == null)
            m_Instance = new Interaction();
        return m_Instance;
    }

    // 获取 ANDROID_ID（无需权限，但可能因设备重置变化）
    public String getAndroidId() {
        String result = Secure.getString(m_Context.getContentResolver(), Secure.ANDROID_ID);
        Log.d("NAVITE-INT","android-id:"+result);
        return result;
    }

    // 触发震动反馈
    public void triggerVibration(int type) {
        m_Vibration.triggerVibration(type);
    }

    // 当前手机是否装有Sim卡
    public boolean hasSimCard(){
        return m_SimCardChecker.hasSimCard();
    }
}